﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter06
{
    public class Code05
    {
        public static void Begin()
        {
            int[] myArray = { 1, 8, 3, 6, 2, 5, 9, 3, 0, 2 };
            int maxVal = MaxValue(myArray);
            Console.WriteLine("The maximun value in myArray is {0}", maxVal);
            Console.ReadLine();
            {
                int var = 1;
                ShowDouble(ref var);
            }
            {
                int var = 1;
                ShowDouble(var);
            }
        }

        private static int MaxValue(int[] intArray)
        {
            int maxVal = intArray[0];
            for (int i = 1; i < intArray.Length; i++)
            {
                if (intArray[i] > maxVal)
                {
                    maxVal = intArray[i];
                }
            }
            return maxVal;
        }

        private static double MaxValue(double[] doubleArray)
        {
            double maxVal = doubleArray[0];
            for (int i = 1; i < doubleArray.Length; i++)
            {
                if (doubleArray[i] > maxVal)
                {
                    maxVal = doubleArray[i];
                }
            }
            return maxVal;
        }

        private static void ShowDouble(ref int val)
        {
            val *= 2;
            Console.WriteLine("val doubled = {0}", val);
        }

        private static void ShowDouble(int val)
        {
            val *= 2;
            Console.WriteLine("val doubled = {0}", val);
        }
    }
}
